package cnm.validator.xpath;

/*
 * Created on Sep 16, 2008 
 *  
 * COPYRIGHT (C) 2008, ZyXEL Corporation (WuXi) Co., Ltd                  
 * Protected as an unpublished work. All Rights Reserved.
 * ZYXEL PROPRIETARY/CONFIDENTIAL.                                               
 * 
 * The computer program listings, specifications, and 
 * documentation herein are the property of ZYXEL 
 * Corporation and shall not be reproduced, copied, 
 * disclosed, or used in whole or in part for any reason 
 * without the prior express written permission of     
 * ZYXEL Corporation.                                    
 */

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

import org.apache.log4j.Logger;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;

/**
 * 
 * @author Harry
 * @version
 *
 */
public abstract class XPathValidator {
	protected static final Logger logger = Logger.getLogger(XPathValidator.class);
    private InputStream in;

    public void setIn(InputStream in) {
        this.in = in;
    }

    public abstract void xpathCheck();

    protected Document createDoc() {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
          factory.setNamespaceAware(true); // never forget this! 
          DocumentBuilder builder = null;
          Document document= null;
          try {
                builder = factory.newDocumentBuilder();
                document = builder.parse(this.in);
                
            } catch (ParserConfigurationException e1) {
              e1.printStackTrace();
          } catch (SAXException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }
        return document;
    }
}
